import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:hibrid_flutter/bridge/flutter_bridge.dart';
import 'package:hibrid_flutter/gen/assets.gen.dart';
import 'package:hibrid_flutter/widget/dir_image.dart';

import '../main.dart';
/// 投资理财页面
class FinancePage extends StatelessWidget {
  final String? params;

  const FinancePage({Key? key, required this.params}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Widget header = Container(
      padding: const EdgeInsets.only(left: 15, right: 15),
      color: Colors.transparent,
      height: 48,
      width: double.infinity,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Padding(
            padding: const EdgeInsets.only(right: 8),
            child: GestureDetector(
              onTap: onLocationTap,
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  DirImage(
                    url: Assets.images.icLocation.path,
                    width: 18,
                    height: 16,
                  ),
                  const Text('北京',
                      style: TextStyle(
                          color: Color(0xfffffaf5),
                          decoration: TextDecoration.none,
                          fontSize: 16))
                ],
              ),
            ),
          ),
          Container(
            margin: const EdgeInsets.only(right: 10),
            decoration: BoxDecoration(
                borderRadius: const BorderRadius.all(Radius.circular(45)),
                color: Colors.transparent,
                border: Border.all(color: const Color(0xfffffaf5), width: 1)),
            height: 32,
            width: MediaQuery.of(context).size.width * 0.5,
            child: Row(
              children: [
                Padding(
                  padding: const EdgeInsets.only(left: 8, right: 8),
                  child: DirImage(
                    url: Assets.images.icSearch.path,
                    width: 18,
                    height: 18,
                  ),
                ),
                const Text('用现金就办现金分期',
                    style: TextStyle(
                        color: Color(0xfffffaf5),
                        decoration: TextDecoration.none,
                        fontSize: 14))
              ],
            ),
          ),
          Expanded(
              child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              DirImage(
                url: Assets.images.icServerWhite.path,
                width: 25,
                height: 25,
              ),
              DirImage(
                url: Assets.images.icMessage.path,
                width: 40,
                height: 40,
              ),
              DirImage(
                url: Assets.images.icAddWhite.path,
                width: 40,
                height: 40,
              ),
            ],
          )),
        ],
      ),
    );
    Widget card = Card(
        child: Container(
      height: 120,
      width: MediaQuery.of(context).size.width - 40,
      padding: const EdgeInsets.all(25),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Expanded(
                  child: Row(
                children: [
                  const Padding(
                    padding: EdgeInsets.only(right: 8),
                    child: Text(
                      '我的投资资产(元)',
                      style: TextStyle(
                          color: Color(0xff696969),
                          decoration: TextDecoration.none,
                          fontSize: 14),
                    ),
                  ),
                  DirImage(
                    url: Assets.images.icEye.path,
                    width: 18,
                    height: 16,
                  ),
                ],
              )),
              Align(
                  alignment: Alignment.centerRight,
                  child: GestureDetector(
                    child: Row(
                      children: const <Widget>[
                        Text(
                          '我的关注',
                          style: TextStyle(
                              color: Colors.orange,
                              decoration: TextDecoration.none,
                              fontSize: 14),
                        ),
                        Text(
                          ' >',
                          style: TextStyle(
                              color: Colors.orangeAccent,
                              decoration: TextDecoration.none,
                              fontSize: 10,
                              letterSpacing: 2),
                        )
                      ],
                    ),
                  ))
            ],
          ),
          const Padding(
            padding: EdgeInsets.only(top: 8),
            child: Text(
              '******',
              style: TextStyle(
                  color: Color(0xff373737),
                  decoration: TextDecoration.none,
                  fontWeight: FontWeight.bold,
                  fontSize: 18),
            ),
          )
        ],
      ),
    ));
    return Scaffold(
      body: Stack(
        children: [
          Container(
            child: DirImage(
              url: Assets.images.financeBg.path,
              width: double.infinity,
              height: 170,
              fit: BoxFit.fitWidth,
            ),
          ),
          Column(
            children: <Widget>[
              header,
              card,
            ],
          )
        ],
      ),
    );
  }

  /// 点击定位按钮，向native端发送消息
  void onLocationTap() {
    FlutterBridge.getInstance().goPointedNativePage({"location":"北京"});
  }
}
